package com.pureut.quality.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.quality.domain.dto.AuditNonconformityDto;
import com.pureut.quality.domain.dto.ExperimentalTemplateSettingsDto;
import com.pureut.quality.domain.vo.AuditNonconformityVo;
import com.pureut.quality.domain.vo.ExperimentalTemplateSettingsVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.service.AuditNonconformityService;
import com.pureut.quality.service.ExperimentalTemplateSettingsService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassDescription: 实验模板设置与数据录入
 * @Author: YSL
 * @Created: 2025/4/8 10:19
 */
@RestController
@RequestMapping("/experimentalTemplate")
public class ExperimentalTemplateSettingsController extends BaseController {


    /**
     * 实验模板设置与数据录入 实现层
     */
    @Resource
    ExperimentalTemplateSettingsService experimentalTemplateSettingsService;

    /**
     * 实验模板设置与数据录入列表
     */
    @RequiresPermissions("experimentManage:experimentTemplate:list")
    @GetMapping("/list")
    public TableDataInfo list(ExperimentalTemplateSettingsVo experimentalTemplateSettingsVo)
    {
        startPage();
        List<ExperimentalTemplateSettingsDto> list = experimentalTemplateSettingsService.selectExperimentalTemplateList(experimentalTemplateSettingsVo);
        return getDataTable(list);
    }

    /**
     * 根据id获取详细信息
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return AjaxResult.success(experimentalTemplateSettingsService.getInfo(id));
    }

    /**
     * 新增实验模板设置与数据录入
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "新增实验模板设置与数据录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody ExperimentalTemplateSettingsVo experimentalTemplateSettingsVo) throws Exception {
        return toAjax(experimentalTemplateSettingsService.insertExperimentalTemplate(experimentalTemplateSettingsVo));
    }

    /**
     * 修改实验模板设置与数据录入
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "修改实验模板设置与数据录入", businessType = BusinessType.INSERT)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody ExperimentalTemplateSettingsVo experimentalTemplateSettingsVo) throws Exception {
        return toAjax(experimentalTemplateSettingsService.updateExperimentalTemplate(experimentalTemplateSettingsVo));
    }

    /**
     * 删除实验模板设置与数据录入
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:remove")
    @Log(title = "删除实验模板设置与数据录入", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") String id){
        return toAjax(experimentalTemplateSettingsService.removeExperimentalTemplate(id));
    }
}
